package com.example.light.system.controller;

import com.example.light.system.common.Result;
import com.example.light.system.dto.allDeviceList;
import com.example.light.system.dto.deviceWorkStatusInfo;
import com.example.light.system.dto.roomTree;
import com.example.light.system.entity.*;
import com.example.light.system.service.impl.IDeviceService;
import com.example.light.system.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Api(description = "设备管理接口")
@RestController
@RequestMapping("/DeviceController")
public class DeviceController {
    @Resource
    IDeviceService iDeviceService;

    @ApiOperation("获取所有教室信息")
    @PostMapping("/getAllRoom")
    public Result<List<room>> getAllRoom(){
        return iDeviceService.getAllRoom();
    }

    @ApiOperation("获取设备类型")
    @PostMapping("/getDeviceType")
    public Result<List<deviceType>> getDeviceType(){
        return iDeviceService.getDeviceType();
    }

    @ApiOperation("获取所有设备信息")
    @PostMapping("/getAllDevice")
    public Result<ArrayList<allDeviceList>> getAllDevice(){
        return iDeviceService.getAllDevice();
    }

    @ApiOperation("查询设备信息")
    @PostMapping("/searchDevice")
    public Result<ArrayList> searchDevice(@RequestBody searchDevice searchDevice){
        return iDeviceService.searchDevice(searchDevice);
    }

    @ApiOperation("新增设备")
    @PostMapping("/addDevice")
    Result<String> addDevice(@RequestBody insertDevice insertDevice){
        return iDeviceService.addDevice(insertDevice);
    }

    @ApiOperation("删除设备")
    @PostMapping("/deleteDevice")
    public Result<String> deleteDevice(String deviceNumber){
        return iDeviceService.deleteDevice(deviceNumber);
    }

    @ApiOperation("编辑设备")
    @PostMapping("/editDevice")
    public Result<String> editDevice(@RequestBody insertDevice insertDevice){
        return iDeviceService.editDevice(insertDevice);
    }

    @ApiOperation("获取房间设备绑定信息树")
    @PostMapping("/getDeviceTree")
    public Result<ArrayList<roomTree>> getDeviceTree(){
        return iDeviceService.getDeviceTree();
    }

    @ApiOperation("获取不同工作状态下的设备数量")
    @PostMapping("/getDeviceWorkStatus")
    Result<deviceWorkStatusInfo> getDeviceWorkStatus(){
        return iDeviceService.getDeviceWorkStatus();
    }

    @ApiOperation("新增灯光模式")
    @PostMapping("/addLightMode")
    public Result<Integer> addLightMode(@RequestBody insertMode insertMode){
        return iDeviceService.addLightMode(insertMode);
    }

    @ApiOperation("获取所有系统灯光模式")
    @PostMapping("/getSystemLightMode")
    public Result<List<mode>> getSystemLightMode(){
        return iDeviceService.getSystemLightMode();
    }

    @ApiOperation("获取所有自定义灯光模式")
    @PostMapping("/getAutoLightMode")
    public Result<List<mode>> getAutoLightMode(){
        return iDeviceService.getAutoLightMode();
    }

    @ApiOperation("获取设备状态")
    @PostMapping("/getDeviceStatus")
    public Result<device> getDeviceStatus(String deviceNumber){
        return iDeviceService.getDeviceStatus(deviceNumber);
    }

    @ApiOperation("获取设备已绑定模式id")
    @PostMapping("/getDeviceMode")
    public Result<Integer> getDeviceMode(String deviceNumber){
        return iDeviceService.getDeviceMode(deviceNumber);
    }

    @ApiOperation("更换绑定模式")
    @PostMapping("/changeMode")
    public Result<String> changeMode(Integer deviceNumber, Integer modeId){
        return iDeviceService.changeMode(deviceNumber, modeId);
    }

    @ApiOperation("删除自定义模式")
    @PostMapping("/deleteMode")
    public Result<String> deleteMode(Integer modeId){
        return iDeviceService.deleteMode(modeId);
    }

    @ApiOperation("控制指令下发")
    @PostMapping("/controlDevice")
    public Result<String> controlDevice(@RequestBody controlParams controlParams){
        return iDeviceService.controlDevice(controlParams);
    }

    @ApiOperation("关闭所有灯光设备")
    @PostMapping("/offLineAllDevice")
    public Result<String> offLineAllDevice(){
        return iDeviceService.offLineAllDevice();
    }

    @ApiOperation("初始化设备使用时长")
    @PostMapping("/getUsedCount")
    public Result<String> getUsedCount(){
        return iDeviceService.getUsedCount();
    }

    @ApiOperation("初始化已开启灯光设备数量数据")
    @PostMapping("/getOnlineDevice")
    public Result<String> getOnlineDevice(){
        return iDeviceService.getOnlineDevice();
    }
}
